package com.yuke.cloud.service.omc;

import com.yuke.cloud.service.omc.service.OdsOrderService;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.concurrent.TimeUnit;

@Slf4j
public class test3 {
    @Autowired
    private OdsOrderService odsOrderService;
    @Autowired
    private RedisTemplate redisTemplate;
    @Test
    public void run() {
//            Integer num = new Integer(1);
//            if (num > 0){
//                System.out.println("10>0"+ (num > 0));
//            }
        redisTemplate.expire("timeOutKey",5,TimeUnit.SECONDS);
        //redisTemplate.opsForValue().set("timeOutKey", "timeOut", 5, TimeUnit.SECONDS);
        String timeOutValue = redisTemplate.opsForValue().get("timeOutKey")+"";
        System.out.println("通过set(K key, V value, long timeout, TimeUnit unit)方法设置过期时间，过期之前获取的数据:"+timeOutValue);
        try{
            Thread.sleep(5*1000);
            timeOutValue = redisTemplate.opsForValue().get("timeOutKey")+"";
            System.out.print(",等待10s过后，获取的值:"+timeOutValue);
        }
        catch(Exception e){
            System.out.println("Wrong!");
        }


//        String currentDate = new SimpleDateFormat("yyyyMMdd").format(new Date());
//        Long num = cacheService.getIncrementNum("demo_get_the_new_" + "test3_"+currentDate);
//        String flowCode = SequenceUtils.getSequence(num);
//        log.info("流水号: " + flowCode);
//        Map map1 = new HashMap();
//        map1.put("status", 1);
//        map1.put("delivering", 2);
//        map1.put("signed", 3);  // add by wg 20190323
//        map1.put("sendTime", 4);
//
//        Object getlogistics =  map1;
//        Map entity = JSON.parseObject(JSON.toJSONString(getlogistics),Map.class);
//        //List<Map> list = Arrays.asList(entity);
//        Object status = entity.get("status");
//        if (status.toString().equals("delivering") || status.toString().equals("signed")) {
//            System.out.println(entity);
//        }
    }
}
